#pragma once
#include<iostream>
#include<string>

using namespace std;

string opers = "+-*/%";

enum
{
    DivZero = 1,
    MoZero,
    Unknown
};

class Task
{
public:
    Task(int x, int y, char op)
        :data1_(x)
        , data2_(y)
        , oper_(op)
        , exitcode(0)
    {}

    void run()
    {
        switch (oper_)
        {
        case '+':
            result = data1_ + data2_;
            break;
        case '-':
            result = data1_ - data2_;
            break;
        case '*':
            result = data1_ * data2_;
            break;
        case '/':
            if (data2_ == 0) exitcode = DivZero;
            else result = data1_ / data2_;
            break;
        case '%':
            if (data2_ == 0) exitcode = MoZero;
            else result = data1_ % data2_;
            break;

        default:
            exitcode = Unknown;
            break;
        }
    }

    void operator()()
    {
        run();
    }

    string GetResult()
    {
        string r = to_string(data1_);
        r += oper_;
        r += to_string(data2_);
        r += "=";
        r += std::to_string(result);
        r += "[code: ";
        r += std::to_string(exitcode);
        r += "]";

        return r;
    }
    std::string GetTask()
    {
        std::string r = std::to_string(data1_);
        r += oper_;
        r += std::to_string(data2_);
        r += "=?";
        return r;
    }
    ~Task()
    {}


private:
    int data1_;
    int data2_;
    char oper_;

    int result;
    int exitcode;
};